package com.jiahe.blog.controller;

import com.jiahe.blog.model.dto.LabelOptionDTO;
import com.jiahe.blog.model.dto.MenuDTO;
import com.jiahe.blog.model.dto.UserMenuDTO;
import com.jiahe.blog.model.response.BlogResponse;
import com.jiahe.blog.model.vo.ConditionVO;
import com.jiahe.blog.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "菜单模块")
@RestController
public class MenuController {

    @Autowired
    private MenuService menuService;

    @ApiOperation(value = "查看菜单列表")
    @GetMapping("/admin/menus")
    public BlogResponse<List<MenuDTO>> listMenus(ConditionVO conditionVO){
        List<MenuDTO> dtoList = menuService.listMenus(conditionVO);
        return BlogResponse.success(dtoList);
    }

    @ApiOperation(value = "查看角色菜单选项")
    @GetMapping("/admin/role/menus")
    public BlogResponse<List<LabelOptionDTO>> listMenuOptions() {
        List<LabelOptionDTO> optionDTOList = menuService.listMenuOptions();
        return BlogResponse.success(optionDTOList);
    }

    @ApiOperation(value = "查看用户菜单")
    @GetMapping("/admin/user/menus")
    public BlogResponse<List<UserMenuDTO>> listUserMenu() {
        List<UserMenuDTO> userMenuList = menuService.listUserMenus();
        return BlogResponse.success(userMenuList);
    }
}
